<%
# Copyright (C) 2013 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
%>

<%
# from https://github.com/instructure/color-slicer, start:270
colors = [
  'rgb(74,118,178)',
  'rgb(79,128,69)',
  'rgb(203,63,119)',
  'rgb(26,127,147)',
  'rgb(146,112,5)',
  'rgb(131,102,180)',
  'rgb(47,130,106)',
  'rgb(203,71,64)',
  'rgb(43,123,169)',
  'rgb(103,125,43)',
  'rgb(184,76,150)',
  'rgb(29,129,133)'
]
%>
<ul id="course_summaries" class="clearfix">
<% @courses.each_with_index do |c, i| %>
  <li class="course_summary span3 border border-trbl">
    <div class="course_text">
      <h3 class="pad-box-mini border border-b" style="background-color: <%= colors[i % colors.count] %>">
        <a href="/courses/<%= c.id %>"><%= c.name %></a>
      </h3>
      <p class="pad-box-mini"><%= c.public_description %></p>
      <% if @current_user && c.open_enrollment && c.self_enrollment_enabled? %>
        <p>
          <a class="btn course_enrollment_link" aria-label="<%= t('Join %{course}', :course => c.name) %>" data-open-as-dialog="" href="/enroll/<%= c.self_enrollment_code %>">
            {{> icons/user-add}}
            {{#t}}Join this Course{{/t}}
          </a>
        </p>
      <% end %>
    </div>
  </li>
<% end %>
</ul>
<% if @prevPage %>
  <a class="pull-left" id="previous-link" href="<%= @prevPage %>">{{#t}}Previous{{/t}}</a>
<% end %>
<% if @nextPage %>
  <a class="pull-right" id="next-link" href="<%= @nextPage %>">{{#t}}Next{{/t}}</a>
<% end %>
